// 实现可调用对象
#include <iostream>
#include <string>
#include <unistd.h>

using namespace std;

enum Status
{
    ok = 0,
    div_zero,
    mod_zero,
    unknow
};

const std::string opers = "+-*/%&^";

class Task
{
public:
    Task()
    {
    }
    Task(int x, int y, char op)
        : _data_x(x), _data_y(y), _oper(op), _result(0), _code(ok)
    {
    }
    void Run()
    {
        switch (_oper)
        {
        case '+':
            _result = _data_x + _data_y;
            break;
        case '-':
            _result = _data_x - _data_y;
            break;
        case '*':
            _result = _data_x * _data_y;
            break;
        case '/':
        {
            if (_data_y == 0)
                _code = div_zero;
            else
                _result = _data_x / _data_y;
            break;
        }
        case '%':
        {
            if (_data_y == 0)
                _code = mod_zero;
            else
                _result = _data_x % _data_y;
            break;
        }
        default:
            _code = unknow;
            break;
        }
    }
    void operator()()
    {
        Run();
    }
    string PrintTask()
    {
        string s;
        s = to_string(_data_x);
        s += " ";
        s += _oper;
        s += " ";
        s += to_string(_data_y);
        s += " ";
        s += "= ?";

        return s;
    }
    string PrintResult()
    {
        string s;
        s = to_string(_data_x);
        s += " ";
        s += _oper;
        s += " ";
        s += to_string(_data_y);
        s += " ";
        s += "=";
        s += " ";
        s += to_string(_result);
        s += " ";
        s += " [";
        s += to_string(_code);
        s += "]";

        return s;
    }
    ~Task()
    {
    }

private:
    int _data_x;
    int _data_y;
    char _oper; // + - * / %

    int _result;
    Status _code; // 结果码，0: 结果可信 !0: 结果不可信，1,2,3,4
};